<?php
class SeoController extends AppController  
{  
    var $uses = array();  
    var $components = array('RequestHandler');
    
    public function beforeFilter() {
        $this->Auth->allow('robots', 'sitemap');
    }
    public function isAuthorized($user) {
        $this->loadModel('User');
        $this->User->id = $user['id'];
        $this->User->unbindModel(array('hasMany' => array('Test')));
        $role = $this->User->read('role');
        if($role['User']['role'] == 'none') {
            if(in_array($this->action, array('robots', 'sitemap'))) {
                return true;
            }
        }
        if($role['User']['role'] == 'admin') {
            if(in_array($this->action, array('robots', 'sitemap'))) {
                return true;
            }
        }
    }
  
    function robots()  
    {  
        if (Configure::read('debug'))  
        {  
            Configure::write('debug', 0);  
        }  
  
        $urls = array(
            '/trainings/add10/',
            '/trainings/addtn/',
            '/trainings/adddh/',
            '/trainings/edittest/',
            '/trainings/deletetest/',
            '/nguoi-dung/',
            '/pho-thong-co-so/che-do-chinh-sua/',
            '/pho-thong-co-so/chinh-sua-ma-de/',
            '/pho-thong-co-so/them-cau-hoi/',
            '/pho-thong-co-so/chinh-sua-cau-hoi/',
            '/pho-thong-co-so/xoa-cau-hoi/',
            '/pho-thong-co-so/reset/',
            '/pho-thong-co-so/xoa-de/',
            '/pho-thong-co-so/tao-de/',
            '/pho-thong-co-so/tron-de/'
        );
  
        // ...snip...  
        // fill the $urls array with those you don't  
        // want to be indexed/crawled  
        // for example  
        //$urls[] = '/articles/view/some-article/commentpaging';  
  
        $this->set('urls', $urls);  
        $this->RequestHandler->respondAs('text');  
        $this->viewPath .= '/text';
        $this->layout = 'ajax';
    }
    function sitemap() {
        $this->RequestHandler->respondAs('xml');  
        $this->viewPath .= '/xml';
        $this->layout = 'ajax';
    }
}  
?>